home *** CD-ROM | disk | FTP | other *** search
/ VRML Browsing & Building Cyberspace / VRML - Browsing and Building Cyberspace.iso / examples / 21.wrl < prev    next >
Text File  |  1995-06-29  |  4KB  |  122 lines

  1. #VRML V1.0 ascii
  2.  
  3. # Example twenty-one - We texture map the Earth with its surface
  4.  
  5. # Here comes the Sun
  6. # The Separator node groups everything within it together
  7. DEF SOLAR_SYSTEM Separator {
  8.  
  9.     # The material will effect all subsequent nodes
  10.     # The sun is yellow, isn't it?  Additive color means red + green = yellow
  11.     # We're switching to emissive color because the Sun gives off light.
  12.     Material {
  13.         emissiveColor 1 1 0        # The Sun emits lots of yellow light
  14.     }
  15.  
  16.     # We'll make the Sun shine here
  17.     # A PointLight shines equally in all directions, like the Sun does.
  18.     DEF SUNLIGHT PointLight {
  19.         intensity 1        # The Sun is way bright
  20.         color 1 1 0.9   # Sunlight is basically white, even though the Sun is yellow.
  21.     }
  22.  
  23.     # The WWWAnchor node is a group node
  24.     # This means that all objects within it are linked with the anchor's URL
  25.     # We want to link the Sun, so the Sun's Sphere node goes inside of it.
  26.     # Using the description field, we provide context for the user
  27.     # The DEF node attaches the name "SUN" to the WWWAnchor group
  28.     DEF SUN WWWAnchor {
  29.         name "http://www.w3.org/" # The root URL of the World Wide Web
  30.         description "A link from the Sun to W3.ORG" # Decriptive text
  31.  
  32.         Sphere {
  33.             radius 10
  34.         }
  35.     }
  36.  
  37.     # We place the Earth within it's own Separator
  38.     # To keep everything good and isolated
  39.     Separator {
  40.  
  41.         # Let's move things out of the way here
  42.         Transform {
  43.             translation 0 20 20
  44.         }
  45.  
  46.         # Color the Earth blue, and make it absorb light
  47.         # But also make it a reflective, like water
  48.         DEF EARTH_MATERIAL Material {
  49.             diffuseColor 0 0 1 # Big blue marble
  50.             specularColor 0.9 0.9 0.9 # And a little more shiny
  51.             shininess 0.9 # Water is rather shiny
  52.         }
  53.  
  54.         Texture2 {
  55.             filename "WORLDMAP.RGB"
  56.         }
  57.  
  58.         # The WWWAnchor node is a group node
  59.         # This means that all objects within it are linked with the anchor's URL
  60.         # We want to link the Earth, so the Earth's Sphere node goes inside of it.
  61.         # Using the description field, we provide context for the user
  62.         # The DEF node attaches the name "Earth" to the WWWAnchor node
  63.         DEF EARTH WWWAnchor {
  64.             name "http://hyperreal.com/~mpesce/book/examples/second.wrl" # Another world
  65.             description "A link to another world" # Decriptive text
  66.  
  67.             # Finally, create the earth
  68.             Sphere {
  69.                 radius 2    # Little Earth
  70.             }
  71.         }
  72.  
  73.         # The Moon gets its own Separator
  74.         # Because we really do keep everything separate
  75.         Separator {
  76.  
  77.             # The Moon is just outside the Earth
  78.             Transform {
  79.                 translation 4 4 0
  80.             }
  81.  
  82.             # Color the Moon grey, make it absorb light
  83.             # It's a little shiny, but not much
  84.             Material {
  85.                 diffuseColor 0.7 0.7 0.7
  86.                 shininess 0.3
  87.             }
  88.  
  89.             # This is a sample texture map
  90.             # Just to show how it all works.
  91.             # Using it, you'll get a 2 x 4 image
  92.             # It's in black/gray/white to make it look like a faux lunar surface
  93.             Texture2 {
  94.                 # Define a 4 x 4 pixel texture map using RGB values
  95.                 image 4 4 3 
  96.  
  97.                 # Here's the map, from lower left to upper right
  98.                 0xC0C0C0 0x808080 0xFFFFFF 0x404040 # Bottom row
  99.                 0x808080 0x202020 0x808080 0xC0C0C0 # Lower Middle Row
  100.                 0x202020 0x808080 0xFFFFFF 0x808080 # Upper Middle Row
  101.                 0x808080 0xC0C0C0 0x808080 0x202020 # Upper Row
  102.             }
  103.  
  104.             # The WWWAnchor node is a group node
  105.             # This means that all objects within it are linked with the anchor's URL
  106.             # We want to link the Moon, so the Moon's Sphere node goes inside of it.
  107.             # Using the description field, we provide context for the user
  108.             # The DEF node attaches the name "Moon" to the WWWAnchor node
  109.             DEF Moon WWWAnchor {
  110.                 name "http://www.cyborganic.com:80/People/paul/The_new_dogs/pescewrd.au"
  111.                 description "Sounds from a talk about VRML"
  112.  
  113.                 # And now, create the Moon
  114.                 Sphere {
  115.                     radius 1    # Tiny Moon
  116.                 }
  117.             }
  118.         }
  119.     }
  120. }
  121.  
  122.